<!-- -*- mode: R -*- -->
  <!--
  ## This program is fre esoftware: you can redistribute it and/or modify
  ## it under the terms of the GNU General Public License as published by
  ## the Free Software Foundation, either version 3 of the License, or
  ## any later version.
  ##
  ## This program is distributed in the hope that it will be useful,
  ## but WITHOUT ANY WARRANTY; without even the implied warranty of
  ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  ## GNU General Public License for more details.
  ##
  ## You should have received a copy of the GNU General Public License
  ## along with this program.  If not, see <http://www.gnu.org/licenses/>.
  -->
  
  <%
setContentType("text/html")
#RApacheOutputErrors(TRUE)
options(hverbose=FALSE,verbose=FALSE)
%>
  
<html>
<head>
<title>Strategico: Show></title>
</head>
<body>

  
  <%
strategico.home <- as.character(Sys.getenv("STRATEGICO_HOME"))
source(file.path(strategico.home, "strategico_util.R"))
project.name <- ifelse(is.null(GET$project), "sample", GET$project)
id <- ifelse(is.null(GET$id), 1, as.numeric(GET$id))
value <- ifelse(is.null(GET$value), "V1", GET$value)
project.config <- GetProjectConfig(project.name=project.name)

project.keys <- GetKeyNames(project.config$keys)

item.path <- GetItemUrl(project.name=project.name, id=id, value=value)
%>
  <center>
    <h1><img src="http://www.r-project.org/Rlogo.jpg" />Strategico :: <%=project.name%></h1>
  </center>
  
                <form method="GET">
                <%=BuildFormElement_project(default=project.name)%>
                <%=BuildHtmlElement_input(label="ID", name="id", default=id, type="text")%>
                <%=BuildFormElement_value(project.name=project.name, default=value)%>
                <input type="submit" value="Show">
                </form>
  <%
db.channel <- DBConnect()

item.summary <- GetItemSummaryDB(project.name=project.name, id=id, db.channel=db.channel, value=value)
item.results <- GetItemResultsDB(project.name=project.name, id=id, db.channel=db.channel, value=value)
DBClose(db.channel)
%>

<h2>Models</h2>
  <img src="<%=paste(item.path,"best_model.png",sep="/")%>" />
  <img src="<%=paste(item.path,"all_models.png",sep="/")%>" />

<h2>Summary</h2>
<%
if(is.data.frame(item.summary)) {
  item.summary <- t(item.summary)
  print(xtable(item.summary), type="html")
}
%>
<h2>Results</h2>
<%
if(is.data.frame(item.results)) {
  item.results$id <- NULL
  item.results$item_id <- NULL
  print(xtable(item.results), type="html")
}
%>

<% ShowTemplate('footer') %>

